package com.neusoft.mybatisdemo.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.neusoft.mybatisdemo.bean.Role;

/**
 * 使用注解开发mybatis，可以同时使用注解和配置文件
 * 
 * @author chens
 *
 */
public interface RoleMapper extends BaseMapper<Role> {

	/**
	 * 查询所有
	 * 
	 * @return list
	 */
	@Select("select roleId id,roleName from role")
	public List<Role> findList();

	/**
	 * 新增
	 * 
	 * @param object
	 * 
	 * @return boolean
	 */
	@Insert("insert into role(roleName) values(#{roleName})")
	public boolean add(Role object);

	/**
	 * 修改
	 * 
	 * @param object
	 * 
	 */
	@Update("update role set roleName=#{roleName} where roleId=#{id}")
	public void edit(Role object);

	/**
	 * 删除
	 * 
	 * @param id
	 * 
	 * @return
	 */
	@Delete("delete from role where roleId=#{id}")
	public int deleteById(Integer id);

}
